<style lang="less" scoped>

</style>
<template>
  <div>
    <el-card>
      <el-row>
        <el-col :span="24">
          <el-form label-width="80px" :inline="true" :model="queryForm" style="margin-top:  5px;" size="mini">
            <el-row>
              <el-col :span="24">
                <el-form-item label="项目归属">
                  <el-select v-model="queryForm.projectid" placeholder="请选择" @change="selectProject"
                             style="width: 150px;">
                    <el-option
                      v-for="item in projectOption"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value">
                    </el-option>
                  </el-select>
                </el-form-item>

                <!--  <el-form-item label="选择时间">
                    <el-date-picker
                      style="width: 150px;"
                      v-model="queryForm.btime"
                      type="date"
                      format="yyyy 年 MM 月 dd 日"
                      value-format="yyyy-MM-dd"
                      placeholder="起始时间">
                    </el-date-picker>
                    -
                    <el-date-picker
                      style="width: 150px;"
                      v-model="queryForm.etime"
                      type="date"
                      format="yyyy 年 MM 月 dd 日"
                      value-format="yyyy-MM-dd"
                      placeholder="结束时间">
                    </el-date-picker>
                  </el-form-item>-->


                <el-form-item label="风机编号">
                  <el-input clearable v-model="queryForm.fjbh" placeholder="风机编号" style="width: 150px;"></el-input>
                </el-form-item>
                <el-form-item>
                  <el-button type="primary" @click="findeTable" icon="el-icon-search"></el-button>
                </el-form-item>
                <el-form-item>
                  <el-button type="danger" @click="reset" icon="el-icon-refresh-left"></el-button>
                </el-form-item>
                <el-form-item>
                  <excelDownLoad @downLoadAll="downLoadAll" @downLoadQuery="downLoadQuery"></excelDownLoad>
                </el-form-item>
                <!-- <el-form-item>
                   <el-button type="warning" @click="showMore" icon="el-icon-d-caret"></el-button>
                 </el-form-item>-->
              </el-col>
            </el-row>

            <transition name="el-zoom-in-bottom">
              <el-row v-show="showmore">
                <el-col :span="24">
                  <el-form-item label="项目归属">
                    <el-select v-model="queryForm.projectid" placeholder="请选择" style="width: 150px;">
                      <el-option
                        v-for="item in projectOption"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value">
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-row>
            </transition>

          </el-form>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-button type="success" plain @click="addProject" size="mini" icon="el-icon-suitcase">添加项目</el-button>
          <el-button type="success" plain @click="addFans" size="mini" icon="el-icon-wind-power">添加风机</el-button>
          <el-button type="primary" plain @click="mangerProject" size="mini" icon="el-icon-suitcase">项目管理</el-button>
          <el-button type="info" plain @click="updateProjectRemark" size="mini" icon="el-icon-suitcase">更新项目备注
          </el-button>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="8" style="margin-top:  5px">
          <el-input
            type="textarea"
            :rows="2"
            placeholder="请输入项目备注内容"
            v-model="projectRemark">
          </el-input>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-table stripe :data="tableData" style="width: 100%" size="mini">
            <el-table-column prop="pname" label="所属项目" width="80" fixed :show-overflow-tooltip="true"></el-table-column>
            <el-table-column prop="fcode" label="风机编号" min-width="110" fixed :show-overflow-tooltip="true">
              <template slot-scope="scope">

              <span v-if="scope.row.state == '1' ">
                <span class="iconfont" style="color: green">&#xe60a;</span>
                {{ scope.row.fcode }}&nbsp;&nbsp;&nbsp;
              </span>


                <span v-if="scope.row.state == '0' ">
                <span class="iconfont" style="color: red">&#xe60a;</span>
                {{ scope.row.fcode }}&nbsp;&nbsp;&nbsp;
              </span>
              </template>
            </el-table-column>

            <el-table-column prop="bwsj" label="并网时间" min-width="110"></el-table-column>
            <el-table-column prop="sjsj" label="首检时间" min-width="110"></el-table-column>

            <el-table-column prop="qnjsj" label="上次全年检" min-width="110"></el-table-column>
            <el-table-column prop="yjxcqnjsj" label="预计下次全年检" min-width="110"></el-table-column>


            <el-table-column prop="bnjsj" label="上次半年检" min-width="110"></el-table-column>
            <el-table-column prop="yjxcbnjsj" label="预计下次半年检" min-width="110"></el-table-column>

            <el-table-column prop="xjsj" label="上次巡检" min-width="110"></el-table-column>
            <el-table-column prop="yjxcxjsj" label="预计下次巡检" min-width="110"></el-table-column>

            <el-table-column prop="remark" label="备注" min-width="150" :show-overflow-tooltip="true"></el-table-column>
            <el-table-column prop="is_con_net" label="是否并网" min-width="80">
              <template slot-scope="scope">
                <el-tag type="success" v-if="scope.row.is_con_net == '1' ">已并网</el-tag>
                <el-tag type="danger" v-if="scope.row.is_con_net == '0' ">未并网</el-tag>
              </template>
            </el-table-column>
            <!--<el-table-column prop="create_time" label="创建时间" min-width="150" :show-overflow-tooltip="true"></el-table-column>
  -->

            <el-table-column label="操作" min-width="110" fixed="right">
              <template slot-scope="scope">
                <el-dropdown split-button size="mini" type="success" @click="editFan(scope.row)" trigger="click">
                  编辑
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item v-if="scope.row.state == '1'" @click.native="changeFanState(scope.row,'禁用','0')">
                      禁用
                    </el-dropdown-item>
                    <el-dropdown-item v-if="scope.row.state == '0'" @click.native="changeFanState(scope.row,'启用','1')">
                      启用
                    </el-dropdown-item>
                    <el-dropdown-item @click.native="deleteFan(scope.row)">删除</el-dropdown-item>
                    <el-dropdown-item>检修记录</el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>


              </template>
            </el-table-column>
          </el-table>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <div style="float: right">
            <el-pagination
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
              :current-page="currentPage"
              :page-sizes="[10, 15, 25, 50]"
              :page-size="pageSize"
              layout="total, sizes, prev, pager, next, jumper"
              :total="total">
            </el-pagination>
          </div>
        </el-col>
      </el-row>
    </el-card>

    <el-dialog title="添加项目" :visible.sync="addProjectDialog" width="25%">
      <el-form :model="project" ref="project" :rules="projectRoule">
        <el-form-item label="项目名称" prop="pname">
          <el-input v-model="project.pname" @keyup.native="removeBlankSpace"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="addProjectDialog = false" size="mini">取 消</el-button>
        <el-button type="primary" @click="insertProject" size="mini">确 定</el-button>
      </div>
    </el-dialog>


    <el-dialog :title="fanTitle" :visible.sync="fansDialog" width="50%" @close="closeFansDialog">
      <el-form :model="fans" :inline="true" ref="fans" :rules="fansRoule" size="mini" label-width="110px"
               label-position="right">
        <el-row>
          <el-col :span="12">
            <el-form-item label="项目名称" prop="attrProjectId">
              <el-select v-model="fans.attrProjectId" placeholder="请选择所属项目">
                <el-option
                  v-for="item in projectOption"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="风机编号" prop="fcode">
              <el-input v-model="fans.fcode" :disabled="fanBtnType =='edit' "></el-input>
            </el-form-item>
          </el-col>
        </el-row>


        <el-row>
          <el-col :span="12">
            <el-form-item label="并网时间" prop="bwsj">
              <el-date-picker
                @change="changeBwsj(fans.bwsj)"
                v-model="fans.bwsj"
                align="right"
                type="date"
                placeholder="选择日期"
                format="yyyy 年 MM 月 dd 日"
                value-format="yyyy/MM/dd">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="首检时间" prop="sjsj">
              <el-date-picker
                @change="changeSjsj(fans.sjsj)"
                v-model="fans.sjsj"
                align="right"
                type="date"
                placeholder="选择日期"
                format="yyyy 年 MM 月 dd 日"
                value-format="yyyy/MM/dd">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>


        <el-row>
          <el-col :span="12">
            <el-form-item label="全年检时间" prop="qnjsj">
              <el-date-picker
                @change="changeQnjsj(fans.qnjsj)"
                v-model="fans.qnjsj"
                align="right"
                type="date"
                placeholder="选择日期"
                format="yyyy 年 MM 月 dd 日"
                value-format="yyyy/MM/dd">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="下次全年检时间" prop="xcqnjsj">
              <el-date-picker
                v-model="fans.xcqnjsj"
                align="right"
                type="date"
                placeholder="选择日期"
                format="yyyy 年 MM 月 dd 日"
                value-format="yyyy/MM/dd">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>


        <el-row>
          <el-col :span="12">
            <el-form-item label="半年检时间" prop="bnjsj">
              <el-date-picker
                v-model="fans.bnjsj"
                @change="changeBnjsj(fans.bnjsj)"
                align="right"
                type="date"
                placeholder="选择日期"
                format="yyyy 年 MM 月 dd 日"
                value-format="yyyy/MM/dd">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="下次半年检时间" prop="xcbnjsj">
              <el-date-picker
                v-model="fans.xcbnjsj"
                align="right"
                type="date"
                placeholder="选择日期"
                format="yyyy 年 MM 月 dd 日"
                value-format="yyyy/MM/dd">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>


        <el-row>
          <el-col :span="12">
            <el-form-item label="巡检时间" prop="xjsj">
              <el-date-picker
                @change="changeXjsj(fans.xjsj)"
                v-model="fans.xjsj"
                align="right"
                type="date"
                placeholder="选择日期"
                format="yyyy 年 MM 月 dd 日"
                value-format="yyyy/MM/dd">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="下次巡检时间" prop="xcxjsj">
              <el-date-picker
                v-model="fans.xcxjsj"
                align="right"
                type="date"
                placeholder="选择日期"
                format="yyyy 年 MM 月 dd 日"
                value-format="yyyy/MM/dd">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>


        <el-row>
          <el-col :span="24">
            <el-form-item label="备注" prop="remark">
              <el-input
                type="textarea"
                style="width: 582px"
                :autosize="{ minRows: 3, maxRows: 6}"
                placeholder="请输入内容"
                v-model="fans.remark">
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>

      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="fansDialog = false" size="mini">取 消</el-button>
        <el-button type="primary" @click="insertFans" v-show="fanBtnType == 'add' " size="mini">确认添加</el-button>
        <el-button type="primary" @click="updateFans" size="mini" v-show="fanBtnType == 'edit' ">确认修改</el-button>
      </div>
    </el-dialog>


    <el-dialog title="项目管理" :visible.sync="projectDialog" width="50%">
      <div style="max-height: 400px;overflow-y: auto">
        <el-card style="margin: 10px;" v-for="item in projectTableData" :key="item.id">
          <span class="medium">项目名：{{ item.pname }}</span>&nbsp;&nbsp;&nbsp;
          <span class="medium">所属风机数：{{ item.fjnum }}</span>&nbsp;&nbsp;&nbsp;
          <el-dropdown split-button type="danger" style="float: right" size="mini" @click="deleteProject(item)"
                       trigger="click">
            删除项目
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item @click.native="renameProject(item)">项目重命名</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </el-card>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="projectDialog = false" size="mini">取 消</el-button>
      </div>
    </el-dialog>


    <el-dialog title="项目重命名" :visible.sync="renameProjectDialog" width="30%">
      <el-form :model="renameProjectData" ref="renameProjectRef" :rules="projectRoule" label-width="80px"
               class="demo-ruleForm">
        <el-form-item label="活动名称" prop="pid" v-show="false">
          <el-input v-model="renameProjectData.pid"></el-input>
        </el-form-item>
        <el-form-item label="项目名" prop="pname">
          <el-input v-model="renameProjectData.pname"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="renameProjectDialog = false" size="mini">取 消</el-button>
        <el-button type="primary" @click="updateProjectName" size="mini">确 定</el-button>
      </span>
    </el-dialog>


  </div>
</template>

<script>
import {timeCompare} from 'untils/timeUntils'
import {dateFormat} from 'untils/dateUntils'
import {request} from 'network/request.js'
import excelDownLoad from "components/excelDownLoad/excelDownLoad";

export default {
  name: "myFans",
  components: {
    excelDownLoad
  },
  data() {
    return {
      queryForm: {
        //项目ID
        projectid: '',
        fjbh: '',
        btime: '',
        etime: '',
      },
      projectOption: [],

      isconintOptions: [{
        value: '0',
        label: '未并网'
      }, {
        value: '1',
        label: '已并网'
      }],


      //一页显示多少条数
      pageSize: 10,
      //但当前页数
      currentPage: 1,
      //总页数
      total: 0,
      tableData: [],


      //添加项目模态框控制属性
      addProjectDialog: false,
      //项目名
      project: {
        pname: '',
      },
      //项目表单校验规则
      projectRoule: {
        pname: [
          {required: true, message: '请输入项目名称', trigger: 'change'},
          {min: 2, max: 12, message: '长度在 2 到 12 个字符', trigger: 'change'}
        ],
      },

      //风机模态框控制属性
      fansDialog: false,
      //完成按钮的类型  有添加与修改  add与edit
      fanBtnType: 'add',
      //风机对象
      fans: {
        //风机ID 在修改风机时 使用
        fid: '',
        //风机时间关联表ID
        ftid: '',
        //风机编号
        fcode: '',
        //所属项目ID
        attrProjectId: '',
        //并网时间
        bwsj: '',
        //首检时间
        sjsj: '',
        //全年检时间
        qnjsj: '',

        xcqnjsj: '',

        //半年检时间
        bnjsj: '',
        xcbnjsj: '',
        //巡检时间
        xjsj: '',
        xcxjsj: '',

        //备注
        remark: '',
      },
      //风机表单校验规则
      fansRoule: {
        fcode: [
          {required: true, message: '请输入风机编码', trigger: 'change'},
        ],
        remark: [
          {required: false, message: '请输入备注', trigger: 'blur'},
          {min: 0, max: 200, message: '长度在 15 到 200 个字符', trigger: 'blur'}
        ],
        attrProjectId: [
          {required: true, message: '请选择风机所属项目', trigger: 'change'},
        ],
        ftype: [
          {required: true, message: '请选择风机类型', trigger: 'change'},
        ],
      },


      showmore: false,
      fanTitle: '添加风机',
      projectDialog: false,

      //项目内容
      projectTableData: [],
      //项目备注数据
      projectRemark: '',

      //重命名项目名模态框显示对象
      renameProjectDialog: false,
      //项目名
      renameProjectData: {
        pid: '',
        pname: ''
      },

    }
  },
  created() {
    this.init()
  },


  watch: {},
  methods: {

    //选择了并网时间
    changeBwsj(data) {
      this.fans.sjsj = dateFormat(data, 180)
      this.fans.xcqnjsj = dateFormat(data, 540)
      this.fans.xcbnjsj = dateFormat(data, 365)
      this.fans.xcxjsj = dateFormat(data, 90)
    },
    //选择了首检时间
    changeSjsj(data) {
      this.fans.xcqnjsj = dateFormat(data, 365)
      this.fans.xcbnjsj = dateFormat(data, 180)
      this.fans.xcxjsj = dateFormat(data, 90)
    },
    //选择了全年检时间
    changeQnjsj(data) {
      this.fans.xcqnjsj = dateFormat(data, 365)
    },
    //选择了半年检时间
    changeBnjsj(data) {
      this.fans.xcbnjsj = dateFormat(data, 365)
    },
    //选择了巡检时间
    changeXjsj(data) {
      this.fans.xcxjsj = dateFormat(data, 180)
    },
    closeFansDialog() {
      Object.keys(this.fans).forEach(key => (this.fans[key] = ""))
    },

    selectProject() {
      //每次重新选择项目时候  应该重置当前页  否则会造成数据无法查询到
      this.currentPage = 1
      this.findeTable()
      this.queryProjectRemark()
    },

    //查询项目备注
    queryProjectRemark() {
      let self = this
      let param = {
        pid: this.queryForm.projectid
      }
      request({url: '/project/queryProjectRemark', data: param}).then(res => {
        self.projectRemark = res.data.data.remark
      })
    },
    //编辑风机
    editFan(data) {
      this.fansDialog = true
      this.fanBtnType = 'edit'
      this.fanTitle = '编辑风机'
      let self = this
      let param = {
        fid: data.fid
      }
      request({url: '/fan/queryFensById', data: param}).then(res => {
        if (res.data.stateCode == '200') {
          self.fans = res.data.data
        }
      })
    },
    //删除风机
    deleteFan(data) {
      this.$confirm('请确认是否删除当前编号为【' + data.fcode + '】的风机?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        let param = {
          fid: data.fid
        }
        let self = this
        request({url: '/fan/deleteFenById', data: param}).then(res => {
          self.findeTable();
          if (res.data.stateCode == '200') {
            self.$message.success(res.data.msg)
          } else {
            self.$message.error(res.data.msg)
          }
        })
      })
    },
    //修改风机状态
    changeFanState(data, mag, state) {
      this.$confirm('确认' + mag + '当前风机吗？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        debugger
        let self = this
        let param = {
          fanid: data.fid,
          state: state
        }

        request({url: '/fan/changeFanState', data: param}).then(res => {
          if (res.data.stateCode == '200') {
            self.$message.success(res.data.msg)
          } else {
            self.$message.error(res.data.msg)
          }
          self.findeTable();
        })
      })
    },
    init() {
      this.initSelectProject()
    },
    initSelectProject() {
      let self = this
      request({url: "/project/initSelectProject", data: {}}).then(res => {
        self.projectOption = res.data.data
        self.queryForm.projectid = self.projectOption[0].value
        self.findeTable()
        self.queryProjectRemark()
      })
    },
    //查询主页表格数据
    findeTable() {
      let self = this
      let timeComp = timeCompare(this.queryForm.btime, this.queryForm.etime)
      if (!timeComp.status) {
        this.$message(timeComp.msg)
        return false
      }
      let param = {
        pageSize: this.pageSize,
        currentPage: this.currentPage,
      }
      Object.assign(param, this.queryForm);
      request({url: '/fan/queryFans', data: param}).then(res => {
        self.tableData = []
        self.total = 0
        self.total = res.data.data.count
        self.tableData = res.data.data.data
      })
    },
    //重置查询
    reset() {
      Object.keys(this.queryForm).forEach(key => (this.queryForm[key] = ""))
    },
    showMore() {
      this.showmore = !this.showmore
    },
    //显示添加项目弹出框
    addProject() {
      this.addProjectDialog = true
      this.project.pname = ''
      this.$nextTick(function () {
        this.$refs['project'].resetFields();
      })
    },
    //显示风机弹出框
    addFans() {
      this.fansDialog = true
      this.fanBtnType = 'add'
      this.fanTitle = '添加风机'
      this.$nextTick(function () {
        this.$refs['fans'].resetFields();
      })
    },
    //项目管理
    mangerProject() {
      let self = this
      request({url: '/project/mangerProject', data: {}}).then(res => {
        if (res.data.stateCode == '200') {
          self.projectDialog = true
          self.projectTableData = res.data.data
        }
      })
    },
    //添加项目
    insertProject() {
      this.$refs.project.validate((valid) => {
        if (valid) {
          let self = this
          request({url: '/project/insertProject', data: self.project}).then(res => {
            if (res.data.stateCode == '200') {
              self.addProjectDialog = false
              self.project.pname = ''
              self.$message.success(res.data.msg)
              self.init()
            } else {
              self.$message.error(res.data.msg)
            }
          })
        }
      })
    },
    //添加风机
    insertFans() {
      this.$refs.fans.validate((valid) => {
        if (valid) {
          let self = this
          request({url: '/fan/insertFans', data: self.fans}).then(res => {
            if (res.data.stateCode == '200') {
              self.fansDialog = false
              self.$message.success(res.data.msg)
              Object.keys(self.fans).forEach(key => (self.fans[key] = ""))
              self.findeTable()
            } else {
              self.$message.error(res.data.msg)
            }
          })
        }
      })
    },
    //修改风机
    updateFans() {
      this.$refs.fans.validate((valid) => {
        if (valid) {
          let self = this
          request({url: '/fan/updateFans', data: self.fans}).then(res => {
            if (res.data.stateCode == '200') {
              self.fansDialog = false
              self.$message.success(res.data.msg)
              Object.keys(self.fans).forEach(key => (self.fans[key] = ""))
              self.findeTable()
            } else {
              self.$message.error(res.data.msg)
            }
          })
        }
      })
    },
    //更新项目备注
    updateProjectRemark() {
      let self = this
      if (this.queryForm.projectid === '') {
        self.$message.error('请选择项目')
        return false
      }
      let param = {
        pid: this.queryForm.projectid,
        remark: this.projectRemark
      }
      request({url: '/fan/updateProjectRemark', data: param}).then(res => {
        if (res.data.stateCode == '200') {
          self.$message.success(res.data.msg)
          self.queryProjectRemark()
        }
      })
    },


    //删除项目
    deleteProject(data) {
      this.$confirm('您确认删除当前项目吗？', '提示', {confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning'})
        .then(() => {
          this.$confirm('该操作会导致关联删除项目下的所有风机数据，确定吗？', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          })
            .then(() => {
              let self = this
              let param = {
                pid: data.id,
              }
              request({url: '/project/deleteProject', data: param}).then(res => {
                if (res.data.stateCode == '200') {
                  self.$message.success(res.data.msg)
                  self.mangerProject()
                  self.findeTable()
                  self.initSelectProject()
                }
              })
            })
        })
    },

    handleSizeChange(val) {
      this.pageSize = val
      this.findeTable()
    },
    handleCurrentChange(val) {
      this.currentPage = val
      this.findeTable()
    },
    removeBlankSpace() {
      this.project.pname = this.project.pname.replace(/\s+/g, "");
    },

    //项目重命名
    renameProject(data) {
      this.renameProjectDialog = true
      this.renameProjectData.pid = data.id
      this.renameProjectData.pname = data.pname
    },

    updateProjectName() {
      this.$refs.renameProjectRef.validate((valid) => {
        if (valid) {
          let self = this
          let param = {
            pid: self.renameProjectData.pid,
            pname: self.renameProjectData.pname,
          }
          request({url: '/project/updateProjectName', data: param}).then(res => {
            if (res.data.stateCode == '200') {
              self.$message.success(res.data.msg)
              self.renameProjectDialog = false
              self.initSelectProject()
            }
          })
        }
      })
    },


    /* let param = {
       pageSize: this.pageSize,
       currentPage: this.currentPage,
     }
     Object.assign(param, this.queryForm);*/

    //文件下载组件的发射事件
    downLoadAll() {
      let data = {
        projectid: this.queryForm.projectid
      }
      this.downLoadFile(data)
    },
    downLoadQuery() {
      let data = {
        pageSize: this.pageSize,
        currentPage: this.currentPage,
      }
      Object.assign(data, this.queryForm);
      this.downLoadFile(data)
    },
    downLoadFile(data) {
      let self = this
      let param = data
      request({
        url: '/excel/downLoadMyFans',
        data: param,
        blob: 'blob'
      }).then(res => {
        if('application/json' == res.data.type){
          self.$message.error('下载失败')
        }else{
          self.$message.success('下载成功')
          let blob = res.data
          let reader = new FileReader()
          reader.readAsDataURL(blob)
          reader.onload = (e) => {
            let a = document.createElement('a')
            a.download = res.headers.filename
            a.href = e.target.result
            document.body.appendChild(a)
            a.click()
            document.body.removeChild(a)
          }
        }
      })
    },

  },
  mounted() {
    /* sessionStorage.setItem()
     sessionStorage.getItem()*/
  }
}
</script>
